Matplotlibヒートマップを作成
- 作成日:2025/04/14
- 更新日:2025/04/14
概要
Fig1. ヒートマップ[1]
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
plt.rcParams["font.family"] = "Arial"
plt.rcParams["font.size"] = 11
mu = np.array([0,0])
sigma = np.array([[50,25],[25,50]])
x, y = np.meshgrid(np.arange(-25, 25, 1), np.arange(-25, 25, 1))
z = np.dstack((x, y))
pdf2 = multivariate_normal.pdf(z, mu, sigma)
fig, axes = plt.subplots(1, 2, figsize=(10.0, 5.0))
axes[0].set_aspect(1)
axes[0].pcolormesh(x, y, pdf2, cmap="jet")
axes[1].set_aspect(1)
axes[1].pcolormesh(x, y, pdf2, cmap="jet", shading="gouraud")